package com.tykboot.dao.sys;

import com.tykboot.core.base.BaseDao;
import com.tykboot.entity.sys.SysRole;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author LiuYu
 */
@Repository
public interface SysRoleDao extends BaseDao<SysRole, Object> {

    @Query("SELECT a FROM SysRole a WHERE EXISTS(SELECT 1 FROM SysUserRole b WHERE a.id = b.roleId AND b.userId = :userId)")
    List<SysRole> queryRolesByUserId(@Param("userId") Integer userId);
}

